<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>修改店员信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../../bangnuo/admin/layui/css/layui.css" media="all">
</head>

<body>

<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin"
     style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">编号</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantUuid" name="assistantUuid" placeholder="请输入用户编号" autocomplete="off"
                   class="layui-input" readonly="readonly">
            <a style="color: red;">用户编号不可修改</a>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-inline">
            <input type="hidden" type="text" id="assistantNumber" name="assistantNumber" placeholder="请输入用户名"
                   autocomplete="off" class="layui-input" readonly="readonly">
            <input type="text" id="assistantUsername" name="assistantUsername" placeholder="请输入用户名" autocomplete="off"
                   class="layui-input" readonly="readonly">
            <a style="color: red;">用户名不可修改</a>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantName" name="assistantName" lay-verify="required" placeholder="请输入真实姓名"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantPhone" name="assistantPhone" lay-verify="phone" placeholder="请输入号码"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantEmail" name="assistantEmail" lay-verify="email" placeholder="请输入邮箱"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantPassword" name="assistantPassword" placeholder="请输入密码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-inline">
            <input type="text" id="assistantCreateTime" name="assistantCreateTime" placeholder="请输入邮箱"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" lay-filter="sex">
        <label class="layui-form-label">选择性别</label>
        <div class="layui-input-block" id="assistantSex">
            <input type="radio" id="sex1" name="assistantSex" value="男" title="男">
            <input type="radio" id="sex2" name="assistantSex" value="女" title="女">
        </div>
    </div>
    <div class="layui-btn-container" style="padding-bottom: 10px; margin-left: 110px; margin-right: -110px;">
        <button class="layui-btn" lay-submit lay-filter="admin-form" data-type="close">立即提交</button>
    </div>
</div>
<script src="../../../../bangnuo/admin/layui/layui.js"></script>
<script src="../../../../bangnuo/admin/js/jquery-1.8.0.min.js"></script>
<script>
    layui.use(['form', 'upload', 'layer'], function () {

        var form = layui.form;

        var resultData;
        var htmls = '<option value="">请选择</option>'; //全局变量

        //检查项目添加到下拉框中
        $.ajax({
            url: '/agentEntity/agent',
            dataType: 'json',
            type: 'get',
            success: function (data) {
                resultData = data.queryResult.list;
                for (var x in resultData) {
                    htmls += '<option value = "' + resultData[x].assistantSex + '">' + resultData[x].name + '</option>';
                }
                $("#assistantSex").html(htmls);
                form.render('radio');
                //重新渲染 固定写法
            }
        })
    });
</script>
<script type="text/javascript">
    layui.use(['form', 'upload', 'layer'], function () {

        var form = layui.form;
        $(function () {
            //获取地址栏路径
            var url = window.location.href;
            //获取“=”的下标
            var pos = url.indexOf("=");
            //获取“=”后的全部字符（用户id）
            var id = url.substring(pos + 1, url.length);
            $.ajax({
                url: "/assistantEntity/findById/" + id,
                contentType: "application/json;charset=UTF-8",
                type: "GET",
                success: function (data) {
                    $("#assistantUsername").val(data.queryResult.list[0].assistantUsername);
                    $("#assistantName").val(data.queryResult.list[0].assistantName);
                    $("#assistantPhone").val(data.queryResult.list[0].assistantPhone);
                    $("#assistantEmail").val(data.queryResult.list[0].assistantEmail);
                    $("#assistantNumber").val(data.queryResult.list[0].assistantNumber);
                    $("#assistantUuid").val(data.queryResult.list[0].assistantUuid);
                    $("#assistantCreateTime").val(data.queryResult.list[0].assistantCreateTime);
                    $("#assistantPassword").val(data.queryResult.list[0].assistantPassword);
                    $("input[name=assistantSex][value='男']").attr("checked", data.queryResult.list[0].assistantSex == '男' ? true : false);
                    $("input[name=assistantSex][value='女']").attr("checked", data.queryResult.list[0].assistantSex == '女' ? true : false);
                    form.render(); //更新全部
                    /* if (data.queryResult.list[0].assistantSex=='男'){
                         $("#sex1").attr("checked","checked");
                         $("#sex2").removeAttr("checked");
                     } else{
                         $("#sex2").attr("checked","checked");
                         $("#sex1").removeAttr("checked");
                     }
                     form.render();*/
                }
            });
        });
    })
</script>
<!--加载表单组件样式-->
<script>
    layui.config({
        base: '../../../../bangnuo/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function () {
        var $ = layui.$,
            form = layui.form,
            upload = layui.upload;

        upload.render({
            elem: '#layuiadmin-upload-useradmin',
            url: layui.setter.base + 'json/upload/demo.js',
            accept: 'images',
            method: 'get',
            acceptMime: 'image/*',
            done: function (res) {
                $(this.item).prev("div").children("input").val(res.data.src)
            }
        });
    })
</script>
<!--获取表单信息，提交表单-->
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        var $ = layui.$,
            form = layui.form,
            layer = layui.layer,
            index = parent.layer.getFrameIndex(window.name); //监听提交
        form.on('submit(admin-form)', function (data) {
            layer.msg(JSON.stringify(data.field));
            $.ajax({
                type: "POST",
                url: "/assistantEntity/upAssistant",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(data.field),
                async: true,
                success: function (data) {
                    if (data.success == true) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg(data.message);
                    }
                }
            });
            return false;
        });

        function cole() {
            var active = {
                close: function () {
                    parent.layer.msg('修改成功');
                    window.parent.location.reload();
                    parent.layer.close(index);
                }
            }
            $('.layui-btn-container .layui-btn').on('click', function () {
                var othis = $(this),
                    type = othis.data('type');
                active[type] && active[type].call(this);
            });
        }
    });
</script>
</body>

</html>